#ifndef T1_H__
#define T1_H__
#include <stdint.h>

#define T1_SBLOCK (0xC0)
#define T1_IFS (0x01)
#define T1_REQUEST (0x00)
#define T1_RESPONSE (0x20)
#define T1_RBLOCK (0x80)

#define T1_SAM_INF_HEADER_ARR {0xA0, 0xDA, 0x02, 0x63, 0x00, 0x00, 0x3F}

typedef uint8_t t1_nad_t;
typedef uint8_t t1_pcb_t;
typedef uint8_t t1_len_t;
typedef uint8_t t1_lrc_t;

typedef struct __attribute__((packed)) {
    uint8_t source;
    uint8_t destination;
    uint8_t reply;
    uint8_t RFU1;
    uint8_t RFU2;
    uint8_t secure_channel;
} payload_header_t;

typedef uint8_t *payload_t;
typedef struct __attribute__((packed)) {
    payload_header_t header;
    payload_t payload;
} t1_inf_t;

typedef struct __attribute__((packed)) {
    t1_nad_t nad;
    t1_pcb_t pcb;
    t1_len_t len;
    t1_inf_t inf[0];
} t1_frame_t;

typedef uint16_t SW1SW2_t;

t1_inf_t *t1_get_inf_field(t1_frame_t *frame);

#endif /* T1_H__ */